<?php
header("Content-Type: text/html; charset=utf-8");
$url = $_REQUEST['url'];

$id_tweet = substr(strrchr($url, '/'), 1);

$jsonurl = "http://api.twitter.com/1/statuses/show/$id_tweet.json";
$json = file_get_contents($jsonurl, 0, null, null);
$tweet = json_decode($json, true);
$user = $tweet['user'];

$date = $tweet['created_at'];
?>
<!DOCTYPE html>
<html class="ui-mobile-rendering">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <title>Twittertido - Procastination everywhere!!!</title>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
        <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
    </head>
    <body>
        <div data-role="page" >

            <div data-role="header">
                <h1>Twittertido</h1>
                <a href="dialog_create.php" data-role="button" data-rel="dialog" data-transition="pop" data-icon="title-tweet" data-iconpos="notext">Delete</a>
            </div><!-- /header -->


            <div data-role="content">
                <div class="ui-body ui-body-b">
                    <div>
                        <div style="white-space: normal; font-size: smaller; font-weight: normal; float: right">
                            <?php print $tweet['created_at']; ?>
                        </div>
                    </div>
                    <div style="clear: both" />
                    <div>
                        <img src="https://api.twitter.com/1/users/profile_image?screen_name=<?php print $user['screen_name']; ?>&size=bigger" style="float: left;  padding-right: 15px; padding-bottom: 5px"  />
                        <div style="white-space: normal; font-weight: bold;"><?php print $user['screen_name']; ?></div>
                    </div>
                    <div style="white-space: normal; font-size: smaller; font-weight: normal; margin-top: 5px"><?php print $tweet['text']; ?></div>
                    <div style="clear: both; " /><hr />
                    <div class="ui-grid-1" style="text-align: center;">
                        <div class="ui-block-a"><?php print $tweet['retweet_count']; ?> retweets</div>
                        <div class="ui-block-b">&nbsp;</div>
                    </div><!-- /grid-a -->
                    <div style="clear: both;" />
                    <form action="send_tweet.php?url=<?php print $url; ?>" method="post">
                        <button type="submit" data-theme="b" name="submit" value="submit-value">Enviar</button>
                    </form>
                </div><!-- /themed container -->
            </div>
        </div>
    </body>
</html>